package com.wuba.rxjavademo.lyz.day0519;

import com.wuba.rxjavademo.lyz.BaseDemo;

import rx.schedulers.Schedulers;
import rx.subjects.PublishSubject;

/**
 * Created by liyaxing on 2016/5/19.
 */
public class Demo01 extends BaseDemo {

    public static void main(String[] ss){
        print("main thread = " + Thread.currentThread().getId());
        PublishSubject<Integer> subject = PublishSubject.create() ;
        subject
            .observeOn(Schedulers.newThread())
            .subscribe(integer -> {
                print("thread = " + Thread.currentThread().getId());
            });
//        subject.flatMap(integer -> {
//            return Observable.create(subscriber -> {
//                subscriber.onNext(integer);
//                print("thread = " + Thread.currentThread().getId());
//            }) ;
//        })

        subject.onNext(1);

        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }

}
